package cn.geckos.flexforum.ui
{
import flash.events.MouseEvent;	

import mx.events.ItemClickEvent;
import mx.collections.ArrayCollection;
import mx.core.UIComponent;
import mx.controls.TextInput;
import mx.controls.CheckBox;

import cn.geckos.flexforum.events.FormEvent;
import cn.geckos.flexforum.GlobalAction;

/**
 * 发出获取新密码事件
 */
[Event(name="orderNewPass", type="cn.geckos.flexforum.events.FormEvent")]

public class LoginForm extends BasicForm
{
	[Bindable]
	protected var linkBarData:ArrayCollection = new ArrayCollection(["lost password", "register"]);
	
	public var uname:TextInput;
	public var pwd:TextInput;
	public var remb:CheckBox;
	public var emailInput:TextInput;
	public var getPassItem:UIComponent;
	
	public function get username():String { return uname.text; }
	public function get password():String { return pwd.text; }
	public function get remember():Boolean { return remb.selected; }
	public function get email():String { return emailInput.text; }
	
	
	public function LoginForm()
	{
		super()
	}
	
	protected function linkBarHandle(e:ItemClickEvent):void
	{
		switch(e.index)
		{
			case 0:
				showUI(getPassItem, true);
				break;
			case 1:
				GlobalAction.getInstance().performMemberRegister();
				break;
			default: break;
		}
	}
	
	protected function orderPassHandle(e:MouseEvent):void
	{
		dispatchEvent(new FormEvent(FormEvent.ORDER_NEW_PASS));
	}
	
}
}